package day12.ReviewJUC;

/*
 * Author: JacksonCoder
 * FileName: FutureTaskDemo
 * Version: 1.0.0
 * Date: 2025/4/22
 */

import java.util.concurrent.Callable;
import java.util.concurrent.FutureTask;

public class FutureTaskDemo {
    public static void main(String[] args) throws Exception {

        Callable<String> callable = () -> "Result from callable";
        FutureTask<String> futureTask = new FutureTask<>(callable);

        new Thread(futureTask).start(); // 启动线程

        String result = futureTask.get(); // 阻塞直到任务完成并获取结果
        System.out.println(result);
    }
}
